import { createRouter, createWebHashHistory, RouteRecordRaw, RouterView } from 'vue-router'
import Layout from '@/layout/AppMain.vue'
// alwaysShow: false
export const constantRoutes:Array<RouteRecordRaw> = [
  {
    path: '/',
    name: '',
    component: Layout,
    redirect: '/dashboard',
    meta: { id: 100 },
    children: [
      {
        path: '/dashboard',
        name: 'Dashboard',
        // @ts-ignore
        component: () => import('@/views/dashboard/dashboard.vue'),
        meta: {
          title: '首页',
          hidden: false,
          alwaysShow: true,
          icon: 'home',
          affix: true // 始终固定在面包屑中
        }
      }
    ]
  },
  {
    path: '/components',
    component: Layout,
    redirect: '/components/table-examples',
    meta: { title: '组件', icon: 'assembly', hidden: false, alwaysShow: true },
    children: [
      {
        path: 'table-examples',
        name: 'tableExamples',
        meta: { title: '表格table', hidden: false, icon: 'table', btnPermissions: ['create', 'modify'] },
        component: () => import('@/views/components/table/tableExamples.vue')
      },
      {
        path: 'form-examples',
        name: 'formExamples',
        meta: { title: '表单form', hidden: false, icon: 'form' },
        component: () => import('@/views/components/form/formExamples.vue')
      },
      {
        path: 'echarts-examples',
        name: 'echartsExamples',
        meta: { title: '图表 chart', hidden: false, icon: 'echarts_line', alwaysShow: true },
        redirect: '/components/echarts-examples/line',
        component: RouterView,
        children: [
          {
            path: 'line',
            name: 'line',
            component: () => import('@/views/components/echarts/line/lineExamples.vue'),
            meta: { title: '折线 chart', hidden: false }
          },
          {
            path: 'bar',
            name: 'bar',
            component: () => import('@/views/components/echarts/bar/barExamples.vue'),
            meta: { title: '柱状 chart', hidden: false }
          },
          {
            path: 'other',
            name: 'other',
            component: () => import('@/views/components/echarts/other/otherExamples.vue'),
            meta: { title: '其他other', hidden: false }
          }
        ]
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/login.vue'),
    meta: {
      title: '登录',
      hidden: true
    }
  }
]

const router = createRouter({
  history: createWebHashHistory(), // 路由模式
  routes: constantRoutes // 路由规则
})

export default router
